<%-- 
    Document   : inc_teacher_form_report
    Created on : Jan 12, 2013, 1:57:42 AM
    Author     : matt
--%>

<%@page import="com.gestionabsences.form.FormTeacherReport"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<c:if test="${ empty resultatQueryListStudents && empty resultatQueryListSeances }">
    <label for="<% out.print(FormTeacherReport.CHAMP_MATIERE);%>">matière</label>
    <select class="matiere" name="<% out.print(FormTeacherReport.CHAMP_MATIERE);%>" id="<% out.print(FormTeacherReport.CHAMP_MATIERE);%>">
	<c:forEach items="${ sessionScope.listeMatieres }" var="mapMatieres" varStatus="boucle">
	    <option value="${ mapMatieres.key }">${ mapMatieres.value }</option>
	</c:forEach>
    </select>
    <c:if test="${ !empty form.erreurs['matiere'] }">
	<p class="help-inline">${form.erreurs['matiere']}</p>
    </c:if>
    <c:if test="${ !empty form.erreurs['erreur'] }">	
	<p class="help-inline">${form.erreurs['erreur']}</p>
    </c:if>

    <input class="btn btn-primary" type="submit" value="Afficher la liste des séances" />
</c:if>
    
<c:if test="${ !empty formGetAbsents }">
    <p>${ formGetAbsents.erreurs['erreur'] }</p>
</c:if>
    
<c:if test="${ !empty resultatInsertion }">
    <p>${ resultatInsertion }</p>
</c:if>

<c:if test="${!empty resultatQueryListSeances && empty resultatQueryListStudents}">
    <input type="hidden" name="<% out.print(FormTeacherReport.CHAMP_MATIERE_SPECIFIE);%>" value="${ formGetMatiere.formerValMatiere }">

    <label for="<% out.print(FormTeacherReport.CHAMP_TYPE_SEANCE);%>">type de séance</label>
    <select class="type_seance" name="<% out.print(FormTeacherReport.CHAMP_TYPE_SEANCE);%>" id="<% out.print(FormTeacherReport.CHAMP_TYPE_SEANCE);%>">
	<option value="" selected>Sélectionnez un élément</option>
	<option value="COURS">Cours</option>
	<option value="TPS">TPs</option>
	<option value="TDS">TDs</option>
    </select>
    <label for="<% out.print(FormTeacherReport.CHAMP_SEANCE);%>">séance</label>
    <select class="seance" name="<% out.print(FormTeacherReport.CHAMP_SEANCE);%>" id="<% out.print(FormTeacherReport.CHAMP_SEANCE);%>">
	<option value="default" selected></option>
	<c:forEach items="${ resultatQueryListSeances.tuples }" var="listSeance" varStatus="boucle">
	    <option class="seance${ listSeance.line[2] }" value="${ listSeance.line[0] }">seance n°${ listSeance.line[0] } ( ${ listSeance.line[2] } ) [ ${ listSeance.line[3] } ]</option>
	</c:forEach>
    </select>
    <c:if test="${ !empty form.erreurs['seance'] }">
	<p class="help-inline">${form.erreurs['seance']}</p>
    </c:if>

    <input class="btn btn-primary" type="submit" value="Afficher la liste des élèves" />

    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
	$('.type_seance').change(function () {	
	    var selectedOption = $('.type_seance option:selected').val();
	    if(selectedOption == "COURS") {
		$('.seanceCOURS').css('display', 'block');
		$('.seanceTPS').css('display', 'none');
		$('.seanceTDS').css('display', 'none');
	    } else if (selectedOption == "TDS"){
		$('.seanceTDS').css('display', 'block');
		$('.seanceTPS').css('display', 'none');
		$('.seanceCOURS').css('display', 'none');
	    } else if (selectedOption == "TPS") {
		$('.seanceTPS').css('display', 'block');
		$('.seanceCOURS').css('display', 'none');
		$('.seanceTDS').css('display', 'none');
	    }
	    $('.seance').val('default');
	})
	.change();
    </script>
</c:if>

<c:if test="${ !empty resultatQueryListStudents }">
    <fieldset>
	<legend>Liste des étudiants</legend>

	<input type="hidden" name="<% out.print(FormTeacherReport.CHAMP_NOMBRE_ETUDIANTS);%>" value="${ formGetSeance.nombreEtudiants }">
	<input type="hidden" name="<% out.print(FormTeacherReport.CHAMP_MATIERE_SPECIFIE);%>" value="${ formGetSeance.formerValMatiere }">
	<input type="hidden" name="<% out.print(FormTeacherReport.CHAMP_SEANCE_SPECIFIE);%>" value="${ formGetSeance.formerValSeance }">
	<input type="hidden" name="<% out.print(FormTeacherReport.CHAMP_TYPE_SEANCE_SPECIFIE);%>" value="${ formGetSeance.formerValTypeSeance }">
	
	<table class="table table-striped">
	    <c:forEach items="${ resultatQueryListStudents.columnsName }" var="nomColonne" varStatus="boucle">
		<th>${ nomColonne }</th>
	    </c:forEach>
	    <th>absent ?</th>
	    </tr>
	    <c:set var="count" value="0" scope="page" />
	    <c:forEach items="${ resultatQueryListStudents.tuples }" var="listTuples" varStatus="boucle">
		<tr>
		    <c:forEach items="${ listTuples.line }" var="listLine" varStatus="boucle">
			<td>${ listLine }</td>
		    </c:forEach>
		    <td><input type="checkbox" name="<% out.print(FormTeacherReport.CHAMP_STUDENT_CHECKED);%>${ count }" value="${ listTuples.line[0] }"></td>
		</tr>
		<c:set var="count" value="${count + 1}" scope="page"/>
	    </c:forEach>
	</table>

	<c:if test="${ !empty formGetListStudent.erreurs['erreur'] }">
	    <p class="help-inline">${formGetListStudent.erreurs['erreur']}</p>
	</c:if>

    </fieldset>
    <input class="btn btn-primary" type="submit" value="Valider"  />
    <input class="btn btn-inverse" type="reset" value="Reset" />
</c:if>